﻿
/*
*  文件名（File Name）：             TemplateViewModel.cs
*  
*  作者（Author）：                  Haotian Zhou 周昊天 
* 
*  日期（Create Date）：             由 GIT 托管
* 
*  功能描述（Assisttion Description）：1、 无。
* 
*  修改记录（Revision Histroy）：    无
* 
*  备注（Remarks）：                 无
* 
*/

using Prism.Commands;
using Prism.Mvvm;
using SEPD.Revit.Extension;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace SEPD.Template.Revit1
{
    public partial class TemplateViewModel : BindableBase
    {

        //当前dll运行目录
        static readonly string assemblyPath = Assembly.GetExecutingAssembly().Location;
        static readonly string assemblyDir = Path.GetDirectoryName(assemblyPath) + "\\";
        //static string templateFileName = assemblyDir + @"_model_\_template_\pip_template.rft";

        //--------------------------------------------------------
        CommonExternalEventHandler executeEventHandler;

        //=============================================

        public ICommand TempCommand { get; set; }
        public ICommand TempCommand2 { get; set; }

        public TemplateViewModel(CommonExternalEventHandler _executeEventHandler)
        {
            this.executeEventHandler = _executeEventHandler;

            PreProccess();

            this.TempCommand = new DelegateCommand(TempExecute);
            this.TempCommand2 = new DelegateCommand(TempExecute2);

        }



        //=============================================

        /// <summary>
        /// 向列表增加
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Ts"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        IEnumerable<T> AddPropertyElement<T>(IEnumerable<T> Ts, T t)
        {
            if (Ts == null) { Ts = new List<T>(); }
            var items = Ts.ToList();
            items.Add(t);
            return items;
        }


        /// <summary>
        /// 向列表属性添加一组项
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Ts"></param>
        /// <param name="ts"></param>
        /// <returns></returns>
        IEnumerable<T> AddPropertyElement<T>(IEnumerable<T> Ts, IEnumerable<T> ts)
        {
            if (Ts == null) { Ts = new List<T>(); }
            var items = Ts.ToList();
            items.AddRange(ts);
            return items;
        }

        /// <summary>
        /// 扣除列表中项
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="Ts"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        IEnumerable<T> DelPropertyElement<T>(IEnumerable<T> Ts, T t)
        {
            var items = Ts.ToList();
            var item = t;
            if (!items.Contains(item) || item == null) { return items; }
            items.Remove(item);
            return items;
        }


        IEnumerable<T> DelPropertyElement<T>(IEnumerable<T> Ts, IEnumerable<T> ts)
        {
            var items = Ts.ToList();
            foreach (var item in ts)
            {
                if (!items.Contains(item) || item == null) { continue; }
                items.Remove(item);
            }
            return items;
        }



        //=============================================

    }
}
